﻿var lang = new Array();
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

function $(id) {
    return document.getElementById(id);
}

Array.prototype.push = function (value) {
    this[this.length] = value;
    return this.length;
}

function checkall(form, prefix, checkall) {
    var checkall = checkall ? checkall : 'chkall';
    for (var i = 0; i < form.elements.length; i++) {
        var e = form.elements[i];
        if (e.name && e.name != checkall && (!prefix || (prefix && e.name.match(prefix)))) {
            e.checked = form.elements[checkall].checked;
        }
    }
}
/**
 * TRS分页方法
 * @param _nPageCount 总页数
 * @param _nCurrIndex 当前页
 * @param _sPageName 文件名
 * @param _sPageExt 文件后缀
 * @param _nRecordCount 记录数
 */
function createPageHTML (_nPageCount, _nCurrIndex, _sPageName, _sPageExt, _nRecordCount) {
    if (_nPageCount && _nPageCount > 1) {
        document.write('<a href="' + _sPageName + '.' + _sPageExt + '">首页</a>');
        var nCurrIndex = _nCurrIndex || 0;
        if (nCurrIndex == 0) {
            //document.write('<a href="#none">上一页</a>');
            //document.write('<a href="#none" class="current">1</a>');
        } else {
            if (nCurrIndex == 1) {
                document.write('<a href="' + _sPageName + '.' + _sPageExt + '">上一页</a>');
            } else {
                document.write('<a href="' + _sPageName + '_' + (nCurrIndex - 1) + '.' + _sPageExt + '">上一页</a>');
            }
            //document.write('<a href="' + _sPageName + '.' + _sPageExt + '">1</a>');
        }
        for (var i = 0; i < _nPageCount; i++) {
            if (10 < _nPageCount && (i < (_nCurrIndex - 5) || i > (_nCurrIndex + 5))) {
                continue;
            }
            if (i == 0) {
                document.write('<a href="' + _sPageName + '.' + _sPageExt + '"' + ((nCurrIndex == i) ? ' class="current" onclick="return false;"' : '') + '>' + (i + 1) + '</a>');
            } else {
                document.write('<a href="' + _sPageName + '_' + i + '.' + _sPageExt + '"' + ((nCurrIndex == i) ? ' class="current" onclick="return false;"' : '') + '>' + (i + 1) + '</a>');
            }
        }
        if (nCurrIndex === (_nPageCount - 1) && _nPageCount > 1) {
            //document.write('<a href="#none">下一页</a>');
        } else {
            document.write('<a href="' + _sPageName + '_' + (nCurrIndex + 1) + '.' + _sPageExt + '">下一页</a>');
        }
        document.write('<a href="' + _sPageName + '_' + (_nPageCount - 1) + '.' + _sPageExt + '">末页</a>');
    }else if (_nRecordCount == '${RECORD_COUNT}'){
		_nRecordCount = 0 ;
    }
    
    document.write('<a href="#none" onclick="return false;">共 ' + _nPageCount + ' 页 ' + _nRecordCount + ' 条</a>');
}